package fit.conceptmap.entities;

import java.io.Serializable;
import javax.persistence.*;
import java.util.Date;
import java.util.List;


/**
 * The persistent class for the assignment database table.
 * 
 */
@Entity
@NamedQuery(name="Assignment.findAll", query="SELECT a FROM Assignment a")
public class Assignment implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	private String idAssignment;

	@Temporal(TemporalType.TIMESTAMP)
	private Date deadLine;

	private String name;

	@Temporal(TemporalType.TIMESTAMP)
	private Date startTime;

	//bi-directional many-to-one association to Conceptmap
	@ManyToOne
	@JoinColumn(name="IDconceptMaps")
	private Conceptmap conceptmap;

	//bi-directional many-to-one association to User
	@ManyToOne
	@JoinColumn(name="owner")
	private User user;

	//bi-directional many-to-one association to MemberAssignment
	@OneToMany(mappedBy="assignment")
	private List<MemberAssignment> memberAssignments;

	public Assignment() {
	}

	public String getIdAssignment() {
		return this.idAssignment;
	}

	public void setIdAssignment(String idAssignment) {
		this.idAssignment = idAssignment;
	}

	public Date getDeadLine() {
		return this.deadLine;
	}

	public void setDeadLine(Date deadLine) {
		this.deadLine = deadLine;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Date getStartTime() {
		return this.startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	public Conceptmap getConceptmap() {
		return this.conceptmap;
	}

	public void setConceptmap(Conceptmap conceptmap) {
		this.conceptmap = conceptmap;
	}

	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public List<MemberAssignment> getMemberAssignments() {
		return this.memberAssignments;
	}

	public void setMemberAssignments(List<MemberAssignment> memberAssignments) {
		this.memberAssignments = memberAssignments;
	}

	public MemberAssignment addMemberAssignment(MemberAssignment memberAssignment) {
		getMemberAssignments().add(memberAssignment);
		memberAssignment.setAssignment(this);

		return memberAssignment;
	}

	public MemberAssignment removeMemberAssignment(MemberAssignment memberAssignment) {
		getMemberAssignments().remove(memberAssignment);
		memberAssignment.setAssignment(null);

		return memberAssignment;
	}

}